package com.moli.iov.admin.web.controller;

import com.moli.iov.admin.model.vo.req.VehicleFenceBindingVo;
import com.moli.iov.admin.service.VehicleFenceBindingService;
import com.moli.iov.base.model.dto.req.VehicleFenceBindingReqDto;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 围栏绑定
 *
 * @author wanghualin
 * @date 2019-09-21 09:13:54
 */
@Slf4j
@RestController
@RequestMapping("/monitor/fenceManagement/vehicleBinding")
public class VehicleFenceBindingController extends BaseController {

  @Autowired
  private VehicleFenceBindingService iVehicleFenceBindingService;

  /**
   * 添加围栏绑定车辆
   */
  @PostMapping("/save")
  public RestResponse saveVehicleFenceBinding(
      @Validated({VehicleFenceBindingVo.Save.class}) @RequestBody VehicleFenceBindingVo vo) {
    assembleUserInfo(vo);
    VehicleFenceBindingReqDto dto = new VehicleFenceBindingReqDto();
    CommonUtils.copyProperties(vo, dto);
    return iVehicleFenceBindingService.saveVehicleFenceBinding(dto);
  }

  /**
   * 删除围栏绑定车辆
   */
  @PostMapping("/delete")
  public RestResponse deleteVehicleFenceBinding(
      @Validated({VehicleFenceBindingVo.Delete.class}) @RequestBody VehicleFenceBindingVo vo) {
    assembleUserInfo(vo);
    VehicleFenceBindingReqDto dto = new VehicleFenceBindingReqDto();
    CommonUtils.copyProperties(vo, dto);
    return iVehicleFenceBindingService.deleteVehicleFenceBinding(dto);
  }

  /**
   * 绑定列表
   */
  @PostMapping("/bindingList")
  public RestResponse bindingList(
      @Validated({VehicleFenceBindingVo.Read.class}) @RequestBody VehicleFenceBindingVo vo) {
    assembleUserInfo(vo);
    VehicleFenceBindingReqDto dto = new VehicleFenceBindingReqDto();
    CommonUtils.copyProperties(vo, dto);
    return iVehicleFenceBindingService.listVehicleFenceBindingList(dto);
  }
  /**
   * 解绑列表
   */
  @PostMapping("/unbindingList")
  public RestResponse unbindingList(
      @Validated({VehicleFenceBindingVo.Read.class}) @RequestBody VehicleFenceBindingVo vo) {
    assembleUserInfo(vo);
    VehicleFenceBindingReqDto dto = new VehicleFenceBindingReqDto();
    CommonUtils.copyProperties(vo, dto);
    return iVehicleFenceBindingService.listVehicleFenceUnbindingList(dto);
  }
  /**
   * 围栏绑定详情列表
   */
  @PostMapping("/detailList")
  public RestResponse detailList(
      @Validated({VehicleFenceBindingVo.Read.class}) @RequestBody VehicleFenceBindingVo vo) {
    assembleUserInfo(vo);
    VehicleFenceBindingReqDto dto = new VehicleFenceBindingReqDto();
    CommonUtils.copyProperties(vo, dto);
    RestResponse restResponse = iVehicleFenceBindingService.listVehicleFenceDetailList(dto);


    return restResponse ;
  }

}
